package team.bailan.entity.domain;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import team.bailan.common.enums.CardTypeEnum;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class CardType {
    public CardTypeEnum cardTypeEnum;
    public int length;
    public int value;

    public static boolean judgeCardType(CardType upcomingCard, CardType discard) {
        System.out.println("upcomingCard:" + upcomingCard);
        System.out.println("discard:" + discard);
        switch (discard.cardTypeEnum) {
            case CARD_WZ:
                return false;
            case CARD_AAAA:
                return upcomingCard.cardTypeEnum == CardTypeEnum.CARD_WZ || upcomingCard.cardTypeEnum == CardTypeEnum.CARD_AAAA && upcomingCard.value > discard.value;
            default:
                break;
        }

        if (judgeBomb(upcomingCard)) {
            return true;
        }
        switch (discard.cardTypeEnum) {
            case CARD_ARBITRARY:
                return upcomingCard.cardTypeEnum != CardTypeEnum.CARD_INVALID;
            case CARD_A:
                return upcomingCard.cardTypeEnum == CardTypeEnum.CARD_A && upcomingCard.value > discard.value;
            case CARD_AA:
                return upcomingCard.cardTypeEnum == CardTypeEnum.CARD_AA && upcomingCard.value > discard.value;
            case CARD_AAA:
                return upcomingCard.cardTypeEnum == CardTypeEnum.CARD_AAA && upcomingCard.value > discard.value;
            case CARD_AAAB:
                return upcomingCard.cardTypeEnum == CardTypeEnum.CARD_AAAB && upcomingCard.value > discard.value;
            case CARD_AAABB:
                return upcomingCard.cardTypeEnum == CardTypeEnum.CARD_AAABB && upcomingCard.value > discard.value;
            case CARD_ABCDE:
                return upcomingCard.cardTypeEnum == CardTypeEnum.CARD_ABCDE && upcomingCard.length == discard.length && upcomingCard.value > discard.value;
            case CARD_AAAABC:
                return upcomingCard.cardTypeEnum == CardTypeEnum.CARD_AAAABC && upcomingCard.value > discard.value;
            case CARD_AABBCC:
                return upcomingCard.cardTypeEnum == CardTypeEnum.CARD_AABBCC && upcomingCard.length == discard.length && upcomingCard.value > discard.value;
            case CARD_AAABBB:
                return upcomingCard.cardTypeEnum == CardTypeEnum.CARD_AAABBB && upcomingCard.length == discard.length && upcomingCard.value > discard.value;
            case CARD_AAAABBCC:
                return upcomingCard.cardTypeEnum == CardTypeEnum.CARD_AAAABBCC && upcomingCard.value > discard.value;
            case CARD_AAABBBCD:
                return upcomingCard.cardTypeEnum == CardTypeEnum.CARD_AAABBBCD && upcomingCard.length == discard.length && upcomingCard.value > discard.value;
            case CARD_AAABBBCCDD:
                return upcomingCard.cardTypeEnum == CardTypeEnum.CARD_AAABBBCCDD && upcomingCard.length == discard.length && upcomingCard.value > discard.value;
            default:
                return false;
        }
    }

    public static boolean judgeBomb(CardType cardType) {
        return cardType.cardTypeEnum == CardTypeEnum.CARD_AAAA || cardType.cardTypeEnum == CardTypeEnum.CARD_WZ;
    }

    @Override
    public String toString() {
        return "CardType{" +
                "cardTypeEnum=" + cardTypeEnum +
                ", length=" + length +
                ", value=" + value +
                '}';
    }
}
